﻿using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dsjsports
{
    class SynchronizationRemoval : SynchronizationInfo
    {
        public SynchronizationRemoval(SynchronizationIObject Sender, string TableName, string AdresDataaBase, int ID)
        {
            this.sender = Sender;
            this.adresDataaBase = AdresDataaBase;
            this.id = ID;
        }

        public string TableName
        {
            get { throw new NotImplementedException(); }
        }

        private SynchronizationIObject sender;
        public SynchronizationIObject Sender
        {
            get { throw new NotImplementedException(); }
        }

        private int id;
        public int ID
        {
            get { return id; }
        }

        public bool Synchronization()
        {
            try
            {
                string updateString = "DELETE FROM спортсмен WHERE спортсмен = " + ID;

                OleDbConnection DataConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + adresDataaBase);
                DataConnection.Open();

                OleDbCommand SQLQuery = new OleDbCommand(updateString, DataConnection);

                int intRecordsAffected = SQLQuery.ExecuteNonQuery();

                DataConnection.Close();

                return true;
            }
            catch
            {
                return false;
            }
        }


        private string adresDataaBase;
        public string AdresDataaBase
        {
            get { throw new NotImplementedException(); }
        }
    }
}
